void
BaseCPU::init()
{
- if (!params()->switched_out)
+ if (!params()->switched_out) {
registerThreadContexts();
+
+ verifyMemoryMode();
+ }
}
void
*/
bool switchedOut() const { return _switchedOut; }
+ /**
+ * Verify that the system is in a memory mode supported by the
+ * CPU.
+ *
+ * Implementations are expected to query the system for the
+ * current memory mode and ensure that it is what the CPU model
+ * expects. If the check fails, the implementation should
+ * terminate the simulation using fatal().
+ */
+ virtual void verifyMemoryMode() const { };
+
/**
* Number of threads we're actually simulating (<= SMT_MAX_THREADS).
* This is a constant for the duration of the simulation.
{
BaseCPU::init();
- if (!params()->switched_out &&
- system->getMemoryMode() != Enums::timing) {
- fatal("The in-order CPU requires the memory system to be in "
- "'timing' mode.\n");
- }
-
for (ThreadID tid = 0; tid < numThreads; ++tid) {
// Set noSquashFromTC so that the CPU doesn't squash when initially
// setting up registers.
resPool->init();
}
+void
+InOrderCPU::verifyMemoryMode() const
+{
+ if (system->getMemoryMode() != Enums::timing) {
+ fatal("The in-order CPU requires the memory system to be in "
+ "'timing' mode.\n");
+ }
+}
+
Fault
InOrderCPU::hwrei(ThreadID tid)
{
/* Destructor */
~InOrderCPU();
+ void verifyMemoryMode() const;
+
/** Return a reference to the data port. */
virtual CpuPort &getDataPort() { return dataPort; }
{
BaseCPU::init();
- if (!params()->switched_out &&
- system->getMemoryMode() != Enums::timing) {
- fatal("The O3 CPU requires the memory system to be in "
- "'timing' mode.\n");
- }
-
for (ThreadID tid = 0; tid < numThreads; ++tid) {
// Set noSquashFromTC so that the CPU doesn't squash when initially
// setting up registers.
return;
DPRINTF(Drain, "Resuming...\n");
-
- if (system->getMemoryMode() != Enums::timing) {
- fatal("The O3 CPU requires the memory system to be in "
- "'timing' mode.\n");
- }
+ verifyMemoryMode();
fetch.drainResume();
commit.drainResume();
_status = Idle;
}
+template <class Impl>
+void
+FullO3CPU<Impl>::verifyMemoryMode() const
+{
+ if (system->getMemoryMode() != Enums::timing) {
+ fatal("The O3 CPU requires the memory system to be in "
+ "'timing' mode.\n");
+ }
+}
+
template <class Impl>
TheISA::MiscReg
FullO3CPU<Impl>::readMiscRegNoEffect(int misc_reg, ThreadID tid)
/** Takes over from another CPU. */
virtual void takeOverFrom(BaseCPU *oldCPU);
+ void verifyMemoryMode() const;
+
/** Get the current instruction sequence number, and increment it. */
InstSeqNum getAndIncrementInstSeq()
{ return globalSeqNum++; }
{
BaseCPU::init();
- if (!params()->switched_out &&
- system->getMemoryMode() != Enums::atomic) {
- fatal("The atomic CPU requires the memory system to be in "
- "'atomic' mode.\n");
- }
-
// Initialise the ThreadContext's memory proxies
tcBase()->initMemProxies(tcBase());
return;
DPRINTF(SimpleCPU, "Resume\n");
- if (system->getMemoryMode() != Enums::atomic) {
- fatal("The atomic CPU requires the memory system to be in "
- "'atomic' mode.\n");
- }
+ verifyMemoryMode();
assert(!threadContexts.empty());
if (threadContexts.size() > 1)
data_write_req.setThreadContext(_cpuId, 0); // Add thread ID here too
}
+void
+AtomicSimpleCPU::verifyMemoryMode() const
+{
+ if (system->getMemoryMode() != Enums::atomic) {
+ fatal("The atomic CPU requires the memory system to be in "
+ "'atomic' mode.\n");
+ }
+}
void
AtomicSimpleCPU::activateContext(ThreadID thread_num, Cycles delay)
void switchOut();
void takeOverFrom(BaseCPU *oldCPU);
+ void verifyMemoryMode() const;
+
virtual void activateContext(ThreadID thread_num, Cycles delay);
virtual void suspendContext(ThreadID thread_num);
{
BaseCPU::init();
- if (!params()->switched_out &&
- system->getMemoryMode() != Enums::timing) {
- fatal("The timing CPU requires the memory system to be in "
- "'timing' mode.\n");
- }
-
// Initialise the ThreadContext's memory proxies
tcBase()->initMemProxies(tcBase());
return;
DPRINTF(SimpleCPU, "Resume\n");
- if (system->getMemoryMode() != Enums::timing) {
- fatal("The timing CPU requires the memory system to be in "
- "'timing' mode.\n");
- }
+ verifyMemoryMode();
assert(!threadContexts.empty());
if (threadContexts.size() > 1)
previousCycle = curCycle();
}
+void
+TimingSimpleCPU::verifyMemoryMode() const
+{
+ if (system->getMemoryMode() != Enums::timing) {
+ fatal("The timing CPU requires the memory system to be in "
+ "'timing' mode.\n");
+ }
+}
void
TimingSimpleCPU::activateContext(ThreadID thread_num, Cycles delay)
void switchOut();
void takeOverFrom(BaseCPU *oldCPU);
+ void verifyMemoryMode() const;
+
virtual void activateContext(ThreadID thread_num, Cycles delay);
virtual void suspendContext(ThreadID thread_num);